// window.onload=function(){
// 		startMore(328);	
// }
// var timer = null;
// var isopen = false;
// function startMore(iTarget){
// 		var oContent = document.getElementById('content'),
// 			oDiamond = document.getElementById('diamond_member');
// 			console.log(oDiamond.offsetTop);
// 			oContent.onclick = function(){
// 				if(!isopen){
// 					isopen=true;
// 						clearInterval(timer);
// 					timer=setInterval(function(){
// 						var speed =(iTarget - oDiamond.offsetHeight)/6;
// 						speed = speed>0?Math.ceil(speed):Math.floor(speed);
// 						if(oDiamond.height==iTarget){
// 							clearInterval(timer); 
// 						}else{
// 							oDiamond.style.height=oDiamond.offsetHeight+speed+'px';
// 						}
// 					},30);
// 				}else{
// 					isopen=false;
// 					clearInterval(timer);
// 					timer=setInterval(function(){
// 						var speed = oDiamond.offsetHeight/6;
// 						speed = speed>0?Math.ceil(speed):Math.floor(speed);
// 						if(oDiamond.height==oDiamond.offsetHeight){
// 							clearInterval(timer); 
// 						}else{
// 							oDiamond.style.height=oDiamond.offsetHeight-speed+'px';
							
// 						}
// 					},30);
// 				}
// 			}
// }

// var timer = null;
// var isopen = false;

function start(){
	var oContent = document.getElementsByClassName('content_class');
	var oDetail = document.getElementsByClassName('detail');
	for(var i = 0;i<oContent.length;i++){

		//console.log(oDetail[i].offsetHeight);
		oDetail[i].style.height='auto';
		oDetail[i].setAttribute('data-h',oDetail[i].offsetHeight);
		oDetail[i].style.height='0';
		oContent[i].onclick = function(){
			//console.log(this.getAttribute('id'));
			var _str =this.getAttribute('id');             //oContent事件的对象
				//console.log(_str.match(/\d+/g)[0]);
			if (_str != null){
				var _num =_str.match(/\d+/g)[0];              //提取id中的数字
				
				startMore(this,_num);
			}
			
		}
	}
}


window.onload=function(){
	start();
}
window.onresize = function() {
  console.log('resize');
  start();
};

function startMore(thisObj,index) {
	//console.log('diamond_member'+index);
	var _obj = 'diamond_content'+index;                   //组合对象字符串
	var oDiamond = document.getElementById(_obj);        //找到对应的对象
	var _newClass =thisObj.getAttribute('class');
	var _showClass =oDiamond.getAttribute('class');

	if(hasClass(oDiamond, "show")){
		_showClass =_showClass.replace('show','');
		oDiamond.setAttribute('class',_showClass);
		oDiamond.style.height= '0';
		_newClass = _newClass.replace('active','');
		thisObj.setAttribute('class', _newClass );
	}else{
		_showClass =_showClass+' show';
		oDiamond.setAttribute('class',_showClass);
		oDiamond.style.height= oDiamond.getAttribute('data-h')+'px';
		_newClass =_newClass+ ' '+'active';
		thisObj.setAttribute('class', _newClass );
	}

	console.log(oDiamond.getAttribute('data-h'));
	
}



var hasClass = (function(){
    var div = document.createElement("div") ;
    if( "classList" in div && typeof div.classList.contains === "function" ) {
        return function(elem, className){
            return elem.classList.contains(className) ;
        } ;
    } else {
        return function(elem, className){
            var classes = elem.className.split(/\s+/) ;
            for(var i= 0 ; i < classes.length ; i ++) {
                if( classes[i] === className ) {
                    return true ;
                }
            }
            return false ;
        } ;
    }
})() ;
//页面加载完成后隐藏所有内容元素 初始化动作
/*var contentElements  = document.querySelectorAll("[id^=diamond_content]");
for(var i = 0;i<contentElements.length;i++){
	contentElements[i].style.display = 'none';
}
*/



// var titles =  document.getElementsByClassName('content_class');

// for(var i = 0;i<titles.length;i++){
// 	titles[i].onclick = function(){
// 		var contentId = "diamond_"+this.getAttribute('id'); //标题对象的内容元素的id
// 		var content = document.getElementById(contentId);  //标题对象对应的内容元素对象
		
// 		//判断元素隐藏或显示
// 		if(content.className.indexOf('show-content') != '-1'){
// 			hideContent(content);
// 		}else{
// 			showContent(content);
// 		}
// 	}
// }


// function showContent(contentObj){
// 	contentObj.className.replace('hide-content','show-content');
// }

// function hideContent(contentObj){
// 	contentObj.className.replace('show-content','hide-content');
// }












	
		
		
		